package com.icngor.service;

import com.icngor.dao.GirlRepository;
import com.icngor.enmus.ResultEnum;
import com.icngor.entity.Girl;
import com.icngor.exception.GirlException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Administrator on 2017/4/8 0008.
 */
@Service
public class GirlService {

    @Autowired
    private GirlRepository girlRepository;

    public void getAge(Integer id) throws GirlException {
        Girl girl = girlRepository.findOne(id);
        Integer age = girl.getAge();
        if ( age < 10) {
            throw new GirlException(ResultEnum.PRIMARY);
        } else if (age < 10 && age < 16) {
            throw new GirlException(ResultEnum.MIDDLE_SCHOOL);
        }
    }
}
